package com.ynny.two_dimensional_array01;

import java.util.Arrays;

public class ArrayDemo01 {

    public static void main(String[] args) {
        //
        //二维数组是 多个一维数组 组成的
        //数据类型[][] 数组名 = new 数据类型[行][列];
        String[][] arrays = new String[3][3];

        //存储值
        arrays[0][0] = "姓名";
        arrays[0][1] = "成绩";
        arrays[0][2] = "等级";

        arrays[1][0] = "张三";
        arrays[1][1] = "89";
        arrays[1][2] = "A";

        arrays[2][0] = "李四";
        arrays[2][1] = "12";


        //取值
        System.out.println(arrays[2][2]);

        //求证 二维数组确实是由一维数组构成?
        String[] firstRow = arrays[0];

        System.out.println(Arrays.toString(firstRow));

        String[] secondRow = arrays[1];


        System.out.println(Arrays.toString(secondRow));

        String[] thirdRow = arrays[2];

        System.out.println(Arrays.toString(thirdRow));



        //快速遍历二维数组
        //arrays.length---->指的是行数
        for (int i = 0; i < arrays.length; i++) {
//------> 每一行的数据
            for (int j = 0; j < arrays[i].length; j++) {

                System.out.print(arrays[i][j] + "\t");
            }

            System.out.println();

        }



    }

}
